package com.jdk.learn.gui;

import javax.swing.*;
import java.awt.*;

/**
 * Created by baiguantao on 2018/1/17.
 */
public class GUIMain {
    private static JFrame frame;
    public static void JFrame(String title){
        frame=new JFrame(title);
        frame.setTitle(title);
//        frame.setBounds(400,300,500,500);


//        frame.setSize(100,100);
    }


    public static void main(String[] args) {
        GUIMain.JFrame("ricky");
        Container pane=frame.getContentPane();
        pane.setLayout(new GridBagLayout());


        GridBagConstraints c = new GridBagConstraints();


        c.anchor = GridBagConstraints.PAGE_START; //页面开始
        c.fill = GridBagConstraints.HORIZONTAL;
//        c.insets = new Insets(0, 0, 0, 0);  //top padding
        c.weightx = 2;//列数占比  比如第二列是1 则是第二列的2倍

        c.gridx = 0;//网格的第一行的第一列
        c.gridy = 0;//网格的第一行
        JTextField ricky00=new JTextField("ricky00");
        pane.add(ricky00, c);



        c.fill = GridBagConstraints.HORIZONTAL;
//        c.insets = new Insets(0, 1, 0, 0);  //top padding
        c.weightx = 1;
        c.weighty = 1;

        c.gridx = 1;//网格的第一行的第二列
        c.gridy = 0;//网格的第一行
        JTextField ricky01=new JTextField("ricky01");
        pane.add(ricky01, c);





        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 1;
        c.ipady = 0;       //reset to default
        c.weighty = 2.0;   //request any extra vertical space
        c.gridx = 0;
        c.gridy = 1;
        c.anchor = GridBagConstraints.PAGE_END; //最后一行
        JTextField rickyend=new JTextField("rickyend");
        pane.add(rickyend, c);



        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 1;
        c.ipady = 0;       //reset to default
        c.weighty = 2.0;   //request any extra vertical space
        c.gridx = 1;
        c.gridy = 1;
        JTextField rickyend2=new JTextField("rickyend2");
        pane.add(rickyend2, c);


        frame.setVisible(true);
        frame.pack();
        frame.setDefaultCloseOperation(1);
    }
}
